home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
dev
/
e
/
amigae21b.lha
/
Amiga_E_v2.1b
/
Sources
/
Other
/
CompLine.e
< prev
next >
Wrap
Text File
|
1992-09-02
|
5KB
|
163 lines
/* E language line precompiler for CygnusEd
CompLine takes the current line from CED, and uppercases all E keywords
in it. It also moves the cursor to the next line. If you don't specify
the 'noindent' command line option, CompLine adds the same amount
of spaces or/and tabs to the beginning of the next line, that the previous
line had.
Installing Compline to CED:
-Select menu 'Begin short invocation macro'
-Press RETURN key
-Select menu 'Send Dos/Arexx command'
-Type 'compline' or 'compline noindent' to the text requester
-Choose OK from the requester 'Would you like.. etc'
-Select menu 'Beg/end definition'
And then save the macros, if you like.
You also probably want to make compline resident, it's much faster that way.
Author:
Teemu Suikki
Internet: tsuikki@lut.fi
Fidonet: 2:221/103.2
*/
OPT OSVERSION=37
MODULE 'rexx/storage','rexxsyslib','exec/nodes'
DEF myport,line[500]:STRING,pos
PROC main()
DEF indent=TRUE
IF InStr(arg,'noindent',0)<>-1 THEN indent:=FALSE
StrCopy(line,'text ',ALL)
IF (rexxsysbase:=OpenLibrary('rexxsyslib.library',0))=0 THEN clean('No ARexx installed!')
IF (myport:=CreateMsgPort())=0 THEN clean('No memory for a message port!')
IF send('status 55',line) THEN clean('Couldn\at get line from CED!')
pos:=TrimStr(line+4) /* count those tabs and spaces */
IF pos[] /* and add them to the end of the string.*/
IF indent THEN StrAdd(line,line+5,pos-line-5)
check()
send('Beg of line',NIL) /* Send the line back to CED */
send('Delete to EOL',NIL)
send(line,NIL)
ELSE
send('text \n',NIL)
ENDIF
clean(0)
ENDPROC
/* This procedure uppercases those keywords */
PROC check()
DEF upper[100]:STRING,quote=0,len,x,a
WHILE Char(pos)
IF quote /* Skip quotes, " or ' */
a:=InStr(pos,[quote*256]:INT,0)
quote:=0
IF a=-1 THEN RETURN
pos:=pos+a+1
ENDIF
x:={separators}
len:=1000000
WHILE Char(x) /* Find the next word */
a:=InStr(pos,x,0)
IF (a>=0) AND (a<len) THEN len:=a
x:=x+2
ENDWHILE
a:=Char(pos+len)
IF (a="'") OR (a=34) THEN quote:=a
StrCopy(upper,pos,len)
UpperStr(upper)
x:={keywords}
WHILE Char(x) AND (StrCmp(upper,x,ALL)=0) DO x:=x+10
IF Char(x) /* Copy uppercased string back */
FOR x:=0 TO len-1 DO PutChar(pos+x,Char(upper+x))
ENDIF
pos:=pos+len+1
ENDWHILE
ENDPROC
PROC clean(error)
IF myport THEN DeleteMsgPort(myport)
IF rexxsysbase THEN CloseLibrary(rexxsysbase)
IF error
EasyRequestArgs(NIL,[20,0,'E line precompiler',error,'OK'],NIL,NIL)
CleanUp(10)
ENDIF
CleanUp(0)
ENDPROC
/* Send an arexx command to CED.
str=string (command) to send
result=string where the result string is _appended_, or NIL. */
PROC send(str,result)
DEF rexxport,msg:PTR TO rexxmsg,argstr,r=FALSE,len
IF msg:=CreateRexxMsg(myport,NIL,NIL)
msg.action:=RXCOMM OR RXFF_STRING OR IF result THEN RXFF_RESULT ELSE 0
IF argstr:=CreateArgstring(str,StrLen(str))
PutLong(msg.args,argstr)
Forbid()
IF rexxport:=FindPort('rexx_ced')
PutMsg(rexxport,msg)
Permit()
WaitPort(myport)
GetMsg(myport)
r:=msg.result1
IF msg.result2
len:=InStr(msg.result2,'\n',0)+1
StrAdd(result,msg.result2,len)
FreeMem(msg.result2,len)
ENDIF
ELSE
Permit()
r:=TRUE
ENDIF
DeleteArgstring(argstr)
ENDIF
DeleteRexxMsg(msg)
ENDIF
ENDPROC r
keywords:
CHAR 'PROC\0.....','ENDPROC\0..','IF\0.......','ENDIF\0....','VOID\0.....',
'WHILE\0....','ENDWHILE\0.','FOR\0......','ENDFOR\0...','SELECT\0...',
'CASE\0.....','DEFAULT\0..','ENDSELECT\0','REPEAT\0...','UNTIL\0....',
'JUMP\0.....','DEF\0......','ELSE\0.....','INCBIN\0...','LONG\0.....',
'INT\0......','CHAR\0.....','INC\0......','DEC\0......','THEN\0.....',
'LOOP\0.....','ENDLOOP\0..','DO\0.......','AND\0......','OR\0.......',
'CONST\0....','OPT\0......','MODULE\0...','STACK\0....','FULL\0.....',
'LARGE\0....','ASM\0......','NOWARN\0...','TO\0.......','STEP\0.....',
'ARRAY\0....','STRING\0...','DIR\0......','PTR\0......','OF\0.......',
'ELSEIF\0...','LIST\0.....','OBJECT\0...','ENDOBJECT\0','SIZEOF\0...',
'RETURN\0...','OSVERSION\0','ENUM\0.....','SET\0......','BUT\0......',
'HANDLE\0...','EXCEPT\0...','RAISE\0....',0
separators:
CHAR ',\0','.\0',':\0',';\0',' \0','=\0','\n\0','`\0','\t\0','\a\0','"\0',0